Skip to content

⚡ Bolt: Optimize format_security_list memory allocations - #136

Merged
ffalcinelli merged 3 commits into
mainfrom
bolt-optimize-config-format-5574614858700912070
Aug 30, 2026
Merged

⚡ Bolt: Optimize format_security_list memory allocations#136
ffalcinelli merged 3 commits into
mainfrom
bolt-optimize-config-format-5574614858700912070

Conversation

@ffalcinelli

Copy link
Copy Markdown
Owner

💡 What:
Updated format_security_list in src/config.rs to accept a &mut String buffer instead of returning a new allocated String. Replaced intermediate Vec allocations and format! macro calls in the loop with direct buffered appending via std::fmt::Write::write! and push_str. Updates were made to to_formatted_string and unit tests to pass the buffer as expected.

🎯 Why:
The original implementation created a new Vec of String components (ref = ..., tag = ..., etc.) and used parts.join(", ") inside a loop for each entry, returning a fully allocated String concatenated to the root TOML buffer. This caused O(N) heap allocations when writing large vetted or compromised security lists, introducing unnecessary overhead during configuration serialization.

📊 Impact:
Significantly reduces memory allocations and CPU overhead when saving configurations with extensive vetted or compromised arrays by streaming string data directly into the final toml_str allocation block.

🔬 Measurement:
Run cargo bench (if set up) or profile memory allocations when writing configurations containing large SecurityEntry lists. Run cargo test to ensure serialization integrity.


PR created automatically by Jules for task 5574614858700912070 started by @ffalcinelli

Replaced string allocations and intermediate Vecs in
`format_security_list` with direct appending via
`std::fmt::Write::write!` to a `&mut String` buffer. This prevents
multiple heap allocations per security entry during config serialization.

Co-authored-by: ffalcinelli <1167082+ffalcinelli@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

google-labs-jules Bot and others added 2 commits August 30, 2026 06:20
Co-authored-by: ffalcinelli <1167082+ffalcinelli@users.noreply.github.com>
Co-authored-by: ffalcinelli <1167082+ffalcinelli@users.noreply.github.com>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.54%. Comparing base (07ac008) to head (5b9f6e7).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #136      +/-   ##
==========================================
+ Coverage   88.51%   88.54%   +0.02%     
==========================================
  Files          28       28              
  Lines        2646     2644       -2     
==========================================
- Hits         2342     2341       -1     
+ Misses        304      303       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ffalcinelli
ffalcinelli merged commit 3df8cae into main Aug 30, 2026
4 checks passed
@ffalcinelli
ffalcinelli deleted the bolt-optimize-config-format-5574614858700912070 branch August 30, 2026 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants